#!/usr/bin/env node

const inquire=require('inquirer');
const path=require('path');
const fs=require('fs')
const ejs=require('ejs')


console.log("working")
inquire.prompt([
  {
    type:"input",
    name:"name",
    message:"your project name ?"
  }
]).then(anwser=>{
 // console.log(anwser)
 //模版目录
 let temp=path.join(__dirname,'templates')
 // 生成目录
 let dir=process.cwd()
   fs.readdir(temp,(err,files)=>{
     if(err)throw err
    // console.log(files)
     files.forEach(file=>{
      ejs.renderFile(path.join(temp,file),anwser,(err,result)=>{
        if(err)throw err
       // console.log(result)
        fs.writeFileSync(path.join(dir,file),result)
      })
     })
   })
})